import request from '@/utils/request'
import { ObjToQueryString } from '@/utils/method'
const baseUrl = process.env.VUE_APP_BASE_API

// 获取开关
export const riskConfig = (params) => {
  return request({
    url: '/business/param/config',
    params,
    method: 'get'
  })
}
// 设置开关
export const setBusinessParam = (data) => {
  return request({
    url: '/business/param/config/setBusinessParam',
    data,
    method: 'put'
  })
}

// 机审业务参数配置
export const getRiskReview = (params) => {
  return request({
    url: '/rule/configs',
    params,
    method: 'get'
  })
}
export const setRiskReview = (data) => {
  return request({
    url: `/rule/config/${data['id']}`,
    data,
    method: 'put'
  })
}
export const exportRiskReview = (params) => {
  const url = '/rule/configs/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
export const getUserSocialIdentityCode = () => {
  return request({
    url: '/rule/userSocialIdentityCode',
    method: 'get'
  })
}
// 机审业务流程配置
// 审核流程
export const getReview = (params) => {
  return request({
    url: '/system/review',
    params,
    method: 'get'
  })
}
export const updateReview = (data) => {
  return request({
    url: '/system/review',
    data,
    method: 'put'
  })
}
export const addReview = (data) => {
  return request({
    url: '/system/review',
    data,
    method: 'post'
  })
}
// 阶段校验
export const systemCheck = () => {
  return request({
    url: '/system/check',
    method: 'get'
  })
}
// 阶段更新
export const systemUpdate = (data) => {
  return request({
    url: '/system/update',
    data,
    method: 'put'
  })
}
// 信审工作配置
export const creditContent = () => {
  return request({
    url: '/creditconfig/creditContent',
    method: 'get'
  })
}
export const updateCreditContent = (data) => {
  return request({
    url: '/creditconfig/updateCreditContent',
    data,
    method: 'post'
  })
}
export const creditTime = () => {
  return request({
    url: '/creditconfig/creditTime',
    method: 'get'
  })
}
export const updateCreditTime = (data) => {
  return request({
    url: '/creditconfig/updateCreditTime',
    data,
    method: 'post'
  })
}

// 第三方接口调用
export const getThirdParty = (params) => {
  return request({
    url: '/third/statement/statistics',
    params,
    method: 'get'
  })
}
export const getExportList = (params) => {
  const url = '/third/statement/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 信审阶段审核数据
export const getStageList = (params) => {
  return request({
    url: '/stage/statement',
    params,
    method: 'get'
  })
}
export const exportStageList = (params) => {
  const url = '/stage/statement/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 包名
export const allPackage = () => {
  return request({
    url: '/channel/package',
    method: 'get'
  })
}
// 信审订单转化报表
export const onLoadGetConversionTop = () => {
  return request({
    url: '/creditAudit/statement/statistics',
    method: 'get'
  })
}
export const getConversionListBottom = (params) => {
  return request({
    url: '/creditAudit/statement',
    params,
    method: 'get'
  })
}
export const exportConversionListBottom = (params) => {
  const url = '/creditAudit/statement/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 考勤绩效
export const getPerformance = (params) => {
  return request({
    url: '/attendance/performance',
    params,
    method: 'get'
  })
}
export const exportPerformance = (params) => {
  const url = '/attendance/performance/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 考勤记录
export const getRecord = (params) => {
  return request({
    url: '/attendance/record',
    params,
    method: 'get'
  })
}
export const exportRecord = (params) => {
  const url = '/attendance/record/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 机审拒绝理由统计数据
export const machineRejectStatistics = (params) => {
  return request({
    url: '/creditAudit/statement/machineRejectStatistics',
    params,
    method: 'get'
  })
}
export const machineRejectStatisticsExport = (params) => {
  const url = '/creditAudit/statement/machineRejectStatistics/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 人审拒绝理由统计数据
export const manpowerRejectStatistics = (params) => {
  return request({
    url: '/creditAudit/statement/manpowerRejectStatistics',
    params,
    method: 'get'
  })
}
export const manpowerRejectStatisticsExport = (params) => {
  const url = '/creditAudit/statement/manpowerRejectStatistics/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 信审记录明细
export const creditAuditRecordDetail = (params) => {
  return request({
    url: '/creditAudit/statement/creditAuditRecordDetail',
    params,
    method: 'get'
  })
}
export const creditAuditRecordDetailExport = (params) => {
  const url = '/creditAudit/statement/creditAuditRecordDetail/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}

// 信审管理台-审核阶段
export const listAuditStage = () => {
  return request({
    url: '/creditAudit/workBench/listAuditStage',
    method: 'get'
  })
}
// 审核拒绝理由
export const listAuditRejectDesc = () => {
  return request({
    url: '/creditAudit/manage/listAuditRejectDesc',
    method: 'get'
  })
}
// 信审公司
export const addCreditReviewFirm = (data) => {
  return request({
    url: '/creditreview/addCreditReviewFirm',
    data,
    method: 'post'
  })
}
export const queryCreditReviewFirm = (params) => {
  return request({
    url: '/creditreview/queryCreditReviewFirm',
    params,
    method: 'get'
  })
}
export const getAllCreditReviewFirm = () => {
  return request({
    url: '/creditreview/getAllCreditReviewFirm',
    method: 'get'
  })
}
export const updateCreditReviewFirm = (data) => {
  return request({
    url: '/creditreview/updateCreditReviewFirm',
    data,
    method: 'post'
  })
}
// 信审小组
export const addCreditReviewGroup = (data) => {
  return request({
    url: '/creditreview/addCreditReviewGroup',
    data,
    method: 'post'
  })
}
export const queryCreditReviewGroup = (params) => {
  return request({
    url: '/creditreview/queryCreditReviewGroup',
    params,
    method: 'get'
  })
}
export const getAllCreditReviewGroup = () => {
  return request({
    url: '/creditreview/getAllCreditReviewGroup',
    method: 'get'
  })
}
export const updateCreditReviewGroup = (data) => {
  return request({
    url: '/creditreview/updateCreditReviewGroup',
    data,
    method: 'post'
  })
}
// 信审成员
export const addCreditReviewStaff = (data) => {
  return request({
    url: '/creditreview/addCreditReviewStaff',
    data,
    method: 'post'
  })
}
export const queryCreditReviewStaff = (params) => {
  return request({
    url: '/creditreview/queryCreditReviewStaff',
    params,
    method: 'get'
  })
}
export const getAllCreditReviewStaff = () => {
  return request({
    url: '/creditreview/getAllCreditReviewStaff',
    method: 'get'
  })
}
export const updateCreditReviewStaff = (data) => {
  return request({
    url: '/creditreview/updateCreditReviewStaff',
    data,
    method: 'post'
  })
}
// 自定义黑名单
export const getBlackList = (params) => {
  return request({
    url: '/blacklist',
    params,
    method: 'get'
  })
}
export const deleteBlackList = (id) => {
  return request({
    url: `/blacklist/delete/${id}`,
    method: 'delete'
  })
}
export const exportBlackList = (params) => {
  const url = '/blacklist/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
export const importBlackList = (data) => {
  return request({
    url: '/blacklist/import',
    data,
    method: 'post'
  })
}
export const templateBlackList = () => {
  const url = '/blacklist/template'
  window.location.href = baseUrl + url
}
export const updateBlackList = (data) => {
  return request({
    url: '/blacklist/update',
    data,
    method: 'put'
  })
}
// 信审订单订单汇总页，查询所有订单，查询接口
export const getCreditAuditData = (params) => {
  return request({
    url: '/creditAudit/manage/get',
    params,
    method: 'get'
  })
}
// 信审订单可分配人员列表
export const getCreditOrderAllocationStaffList = (params) => {
  return request({
    url: '/creditAudit/workBench/getCreditOrderAllocationStaffList',
    params,
    method: 'get'
  })
}
// 分配
export const allocationCreditOrder = (data) => {
  return request({
    url: '/creditAudit/workBench/allocation',
    data,
    method: 'put'
  })
}
// 信审订单-流转记录
export const getCreditOrderFlowHistory = (id) => {
  return request({
    url: `/creditAudit/workBench/getCreditOrderFlowHistory/${id}`,
    method: 'get'
  })
}
// 信审记录
export const riskAuditDetail = (params) => {
  return request({
    url: '/creditAudit/workBench/riskAudit/detail',
    params,
    method: 'get'
  })
}
// 导出
export const exportCreditOrder = (params) => {
  const url = '/creditAudit/manage/exportCreditOrderList'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 确定批量关闭/拒绝/回退阶段
export const batchCloseOrRejectOrRollbackStage = (data) => {
  return request({
    url: '/risk/batchCloseOrRejectOrRollbackStage',
    data,
    method: 'put'
  })
}
// 审核拒绝理由
export const queryAuditRejectDesc = () => {
  return request({
    url: '/creditAudit/workBench/queryAuditRejectDesc',
    method: 'get'
  })
}
// 组内已审核列表
export const getGroupAuditList = (params) => {
  return request({
    url: '/creditAudit/workBench/getGroupAuditList',
    params,
    method: 'get'
  })
}
// 考勤记录
export const attendance = (params) => {
  return request({
    url: '/creditAudit/workBench/attendance',
    params,
    method: 'get'
  })
}
export const exportAttendance = (params) => {
  const url = '/creditAudit/workBench/attendance/export'
  if (params) {
    const data = ObjToQueryString(params)
    window.location = baseUrl + url + '?' + data.slice(0, -1)
  } else {
    window.location = baseUrl + url
  }
}
// 查询本登录人员的信审员工
export const getCurrentStaffId = () => {
  return request({
    url: '/creditreview/getCurrentStaffId',
    method: 'get'
  })
}
// 查询信审人员签到状态
export const querySiginStatus = () => {
  return request({
    url: '/creditAudit/workBench/signIn/state',
    method: 'get'
  })
}
// 签到
export const goSignIn = () => {
  return request({
    url: '/creditAudit/workBench/signIn',
    method: 'post'
  })
}
// 签退
export const goSignOut = () => {
  return request({
    url: '/creditAudit/workBench/signOut',
    method: 'delete'
  })
}
// 信审操作台列表
export const getAuditList = (params) => {
  return request({
    url: '/creditAudit/workBench',
    params,
    method: 'get'
  })
}
// 根据id查询信审人员信息
export const getCurrentCreditAuditStaff = () => {
  return request({
    url: '/creditAudit/workBench/getCurrentCreditAuditStaff',
    method: 'get'
  })
}
// 查看订单是否分配给其他人员
export const lockUnauditCreditOrder = (orderId) => {
  return request({
    url: `/creditAudit/workBench/lockUnauditCreditOrder/${orderId}`,
    method: 'post'
  })
}
